package com.example.wx.util;


import com.example.wx.modle.message.Item;
import com.thoughtworks.xstream.XStream;

/**
 * @author: ZhangBin
 * @date: 2025/4/2 14:33
 * @description: 对象转化为xml格式（最后是一个字符串的xml）
 */
public class Obj2XmlUtil {

    public static String objToXml(Object obj, String rootElement) {
        XStream xStream = new XStream();
        xStream.alias(rootElement, obj.getClass());//将根标签转化为指定的根标签
        xStream.alias("item", Item.class);
        return xStream.toXML(obj);
    }
}
